
// <copyright file="SharedStopWatch.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   Wraps an instance of System.Diagnostics.StopWatch and shares it.
//   StopWatch uses a High Resolution Timer. Having many instances of a StopWatch is a performance hit.
//   So, it is recommended to use a shared StopWatch. This static class serves this purpose.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Diagnostics
{
    using System;
    using System.Diagnostics;

    /// <summary>
    ///     Wraps an instance of System.Diagnostics.StopWatch and shares it.
    ///     StopWatch uses a High Resolution Timer. Having many instances of a StopWatch is a performance hit.
    ///     So, it is recommended to use a shared StopWatch. This static class serves this purpose.
    /// </summary>
    public static class SharedStopWatch
    {
        #region Static Fields

        /// <summary>
        /// The sw.
        /// </summary>
        private static readonly Stopwatch _sw = Stopwatch.StartNew();

        #endregion Static Fields

        #region Public Properties

        /// <summary>
        /// Gets the elapsed.
        /// </summary>
        public static TimeSpan Elapsed
        {
            get
            {
                return _sw.Elapsed;
            }
        }

        /// <summary>
        ///     The number of ticks elapsed so far after this timer is started
        /// </summary>
        public static long ElapsedTicks
        {
            get
            {
                return _sw.Elapsed.Ticks;
            }
        }

        #endregion Public Properties
    }
}
